﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiaryPlanner
{
    public partial class PhotoViewer : Form
    {
        public Album thisAlbumObject;
        public int index;//photolist index
        public int count;

        public PhotoViewer(Album ab)
        {
            thisAlbumObject = ab;
            InitializeComponent();

            photoMemo.Text = ab.nowPhoto.photoMemo;
            nowPhoto.Image = ab.nowPhoto.Image;


            count = thisAlbumObject.nowFolder.PhotoList.Count;
            foreach (AlbumPhoto ap in thisAlbumObject.nowFolder.PhotoList)
            {
                if (thisAlbumObject.nowPhoto != ap)
                {
                    index++;
                }
                else                {
                    //nowphoto                                      
                    break;
                }
            }
            
        }

        private void pictureBox1_Click(object sender, EventArgs e)//다음 이미지 버튼
        {                               
                if (index+1 < count)
                {
                    index++;//다음 index
                    AlbumPhoto apt = thisAlbumObject.nowFolder.PhotoList[index] as AlbumPhoto;
                    thisAlbumObject.nowPhoto = apt;

                    //view
                    nowPhoto.Image = apt.Image;
                    photoMemo.Text = apt.photoMemo;
                }   
        }

        private void pictureBox2_Click(object sender, EventArgs e)
        {
            if (index - 1 >=0)
            {
                index--;//이전 index
                AlbumPhoto apt = thisAlbumObject.nowFolder.PhotoList[index] as AlbumPhoto;
                thisAlbumObject.nowPhoto = apt;

                //view
                nowPhoto.Image = apt.Image;
                photoMemo.Text = apt.photoMemo;
            }
            
        }

       
    }
}
